class Solution {
    public int searchInsert(int[] nums, int target) {
        //二分查找
        int len = nums.length;
        int right = len - 1;
        int left = 0;
        int mid = 0;
        int re = len;
        while(left <= right){
            mid = (left + right)/2;
            if (target <= nums[mid]) {
                re = mid;
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        // if(nums[mid] > target) mid+1;
        return re;
    }
}